#pragma once

#include "MenuButton.h"
#include "DirectInput.h"
#include "Player.h"
#include <vector>

#include "MsgInfo.h"


// Menu Class


class Menu
{
private:
	typedef std::vector<MenuButton*>			Vec_Quadrants;
	typedef std::vector<MenuButton*>			Vec_Sectors;
	typedef std::vector<MenuButton*>			Vec_GButtons;
	typedef std::vector<MenuButton*>			Vec_QButtons;
	
	Vec_Quadrants	vQuads;
	Vec_Sectors		vSects;
	Vec_GButtons	vGButtons;
	Vec_QButtons	vQButtons;

	ID3DXFont				*m_pFont;			// Font Object
	ID3DXFont				*m_subFont;			// Font for submenus
	IDirect3DTexture9		*m_pTexture;		//texture object
	IDirect3DTexture9		*m_pGridTexture;		//texture object
	ID3DXSprite				*m_pSprite;			//Sprite object
	
	D3DXIMAGE_INFO			m_imageInfo;		// File details of a texture


	D3DXVECTOR2				m_sectorPos[MAX_SECTORS];
	int						m_sectorSelected;

	D3DXVECTOR2				m_QuadPos[MAX_SECTORS];
	int						m_QuadSelected;

	bool					m_galaxy;			//"state" of the map, Galaxy (true), Quadrant(false)
	bool					m_clicked;

	MenuButton*				m_button;			//pointer to menubutton class


	//MenuState				m_menuState;
	HWND					hWnd;

	float					m_BBx;
	float					m_BBy;

	//float					BUTTON_MENU_POS_X;
	//float					BUTTON_MENU_POS_Y;

	RECT					rect;		//rect for text drawing

	bool					m_pressedPlay;

	bool					m_mouseDown;
	bool					m_windowed;

	bool					m_musicMute;
	bool					m_soundMute;

	float					m_SoundVolume;
	float					m_MusicVolume;

public:
	Menu();
	~Menu();
	MsgInfoIn				m_msgIn;
	MsgInfoOut				m_msgOut;

	void MenuInit(HWND hW, float x, float y);	//load/initialize assets

	void LoadMap(void);	//loads map grid
	void DrawMap(void);	//draws map grid

	void LoadGButtons(void);//loads ui command buttons for galaxy
	void DrawGButtons(void);//draws UI buttons for galaxy

	void LoadQButtons(void);//loads ui command buttons for galaxy
	void DrawQButtons(void);//draws UI buttons for galaxy

	void CheckButtons(void); //checks which buttons are pushed


	void SetGalaxy(bool g) { m_galaxy = g;}

	void MenuInput(void);	//Reads mouse input from user

	void Update(float dt,float BBx, float BBy);
	void Render(void);

	void MenuText(void);		
	void Systemstext(void);		//displays on/offline systems
	D3DXVECTOR2 GetSectorPos() {return m_sectorPos[m_sectorSelected];}
	D3DXVECTOR2 GetSectorPos(int a) {m_sectorSelected = a; return m_sectorPos[a];}

	D3DXVECTOR2 GetQuadPos() {return m_QuadPos[m_QuadSelected];}
	D3DXVECTOR2 GetQuadPos(int a) {m_QuadSelected = a; return m_QuadPos[a];}

	MsgInfoIn GetMsgIn()		{return m_msgIn;}
	MsgInfoOut GetMsgOut()		{return m_msgOut;}

	bool getClick(void)	{return m_clicked;}
	void SetClick(bool c)	{m_clicked = c;}

	//change menu states based on button clicked
//	void ChangeMenuStates(MenuState ms)	{m_menuState = ms;};

	//draw sub-menus
	void ShowHelp(void);
	//void ShowOptions(void);
	void ShowCredits(void);

	void DrawBackButton(void);		//draws the back button to sub menus
	void ClickBack(void);			//checks if the back button is clicked in sub menus

	bool getGalaxy(void)	{return m_galaxy;}	//rreturns whether or not player pressed playbutton
	//void ClickFullScreen(void);			//checks if the Fullscreen button is clicked

	void OnLostDevice(void);	// performs necessary functions when a device is lost
	void OnResetDevice(void);	// performs necessary functions when a device is reset

	void MenuClear(void);		//release/delete data

	void Reset(void);			// Resets menu parameters in case we return to the menu later
};